import { ListPage } from "custom/index";
import { getCheckPagePage } from './api'
import CheckPageTableBefore from './custom/CheckPageTableBefore'
import TableBefore from './component/CheckPageTableBefore.vue'
import checkPageDetailDialog from './dialog/check-page-detail-dialog'
const tableBefore = new CheckPageTableBefore('DataQueryHistoryTableBefore')
tableBefore.setComponent(TableBefore)
import dayjs from 'dayjs'

const getParams = ctx => {
  const { props } = ctx
  return { url: 'DataQueryAnalysis5', condition: props.query, sort: props.sort }
}

const page = new ListPage('DayPage');

page
  .api(getCheckPagePage)
  .useSearch()
    .useInputItem('keyword', '客户名称/店铺名称').showColumns(false).end()
    .addDictSelect({ prop: 'customPostType', label: '岗位类别' }, 'customPostType')
    .addDictSelect({ prop: 'customGroup', label: '客服分组' }, 'customGroup')
    .useDateRangePicker(['dateStart', 'dateEnd'], { label: '日期', clearable: false }).setDefault(dayjs().subtract(2, 'day').format('YYYY-MM-DD'), 'dateStart').setDefault(dayjs().subtract(1, 'day').format('YYYY-MM-DD'), 'dateEnd').upto('PageSearch')
    .end()
  .useTable()
    .useIndexColumn().end()
    .useColumn('dateStart').label('开始日期').minWidth(130).end()
    .useColumn('dateEnd').label('结束日期').minWidth(130).end()
    .useColumn('customTypeName').label('客服类型').showOverflowTooltip().minWidth(160).end()
    .useColumn('name').label('客服姓名').minWidth(200).end()
    .useColumn('flowerName').label('客服花名').minWidth(160).end()
    .useColumn('no').label('客服工号').minWidth(200).end()
    .useColumn('sumReceptionVolume').label('总接待量').toFixed(2).minWidth(200).end()
    .useColumn('sumIgnoreReceptionVolume').label('标后总量').toFixed(2).minWidth(140).end()
    .useColumn('averageDayReceptionVolume').label('日均接待量').toFixed(2).minWidth(140).end()
    .useColumn('averageIgnoreDayReceptionVolume').label('标后日均').toFixed(2).minWidth(140).end()
    .useColumn('averageResponseTime').label('平均响应').toFixed(2).minWidth(140).end()
    .useColumn('averageIgnoreResponseTime').label('标后均响').toFixed(2).minWidth(140).end()
    .useColumn('averageResponseRate').label('平均回复率').toFixedPercent(2).minWidth(140).end()
    .useColumn('averageIgnoreResponseRate').label('标后回复').toFixed(2).minWidth(140).end()
    .useColumn('averageConversionRate').label('平均问答比').toFixedPercent(2).minWidth(140).end()
    .useColumn('averageIgnoreQARatio').label('标后问答').toFixed(2).minWidth(140).end()
    .useColumn('sumCount').label('数据总行数').toFixed(2).minWidth(140).end()
    .useColumn('ignoreCount').label('打标行数').toFixed(2).minWidth(140).end()
    .useColumn('ignoreProportion').label('打标占比').minWidth(140).end()
    .useColumn('restDays').label('休息天数').minWidth(140).end()
    .end()
  .usePagination()
    .end()
  .useAuthColumn()
    .useItem().content('详情').editRow(checkPageDetailDialog).end()
    .end()
  .useAuthButton()
    .useItem('').content('导出').exportExcel(getParams).end()
    .end()
  .addChild(tableBefore, 'table-before')

export default page
